//
// Created by Jisam on 2024/7/27 20:15.
// solve B - Grid Walk
#include <bits/stdc++.h>

#define PSI pair<string,int>
#define PII pair<int,int>
#define PDI pair<double,int>
#define PDD pair<double,double>
#define VVI vector<vector<int>>
#define VI vector<int>
#define VS vector<string>

#define PQLI priority_queue<int, vector<int>, less<int>>
#define PQGI priority_queue<int, vector<int>, greater<int>>
#define i64 long long

using namespace std;


void solve() {
    int h, w, si, sj;
    cin >> h >> w >> si >> sj;
    vector<string> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }
    string s;
    cin >> s;
    si --;
    sj --;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'U' && si - 1 >= 0 && a[si - 1][sj] == '.') {
            si--;
        } else if (s[i] == 'D' && si + 1 < h && a[si + 1][sj] == '.') {
            si++;
        } else if (s[i] == 'L' && sj - 1 >= 0 && a[si][sj - 1] == '.') {
            sj--;
        } else if (s[i] == 'R' && sj + 1 < w && a[si][sj + 1] == '.') {
            sj++;
        }
//        cout << s[i] << "    "<< si + 1<< " " << sj + 1 <<"\n";


    }
    cout << si + 1  << " " << sj + 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    while (T--) solve();
    return 0;
}